package jpao.benchmark.metric;

/**
 *
 * @author soa
 */
public final class MetricConverter {
    
    /** the scale to convert nano to micro. */
    public static final double NANO_TO_MICRO_SCALE = 1d / 1000d;

    public static Metric convertNanosecondToMicrosecond(Metric nanosecondMetric) {
        
        // check unit
        if (!Unit.NANOSECOND_UNIT.equals(nanosecondMetric.getUnit())) {
            throw new IllegalArgumentException("Metric is not in " + Unit.NANOSECOND_UNIT.getName() + ": " + nanosecondMetric.getUnit());
        }
        
        // convert
        return new Metric(nanosecondMetric.getMeasure() * NANO_TO_MICRO_SCALE, Unit.MICROSECOND_UNIT);
    }
}
